<div class="cars index">
    <div id="filtro_busqueda" class="filtro">
        <fieldset>
            <legend>Busqueda</legend>
            <?php echo $form->create('Car', array('url' => array('controller' => 'cars', 'action' => 'index'))); ?>
            <?php
            echo $form->input('letra', array('label' => 'Letra Patente', 'maxlength' => 3));
            echo $form->input('numero', array('label' => 'Número Patente', 'maxlength' => 3));
            echo $form->submit(__('Buscar', true));
            echo $form->end();
            ?>
        </fieldset>
    </div>
    <h2 class="left"><?php echo $html->image('iconos/cars.png');
__('Autos'); ?></h2>
    <div class="actions specific">
        <ul>
            <li><?php echo $this->Html->link(__('Nuevo Auto', true), array('action' => 'add')); ?></li>
        </ul>
    </div>
    <div class="clear"></div>
    <table cellpadding="0" cellspacing="0">
        <tr>
<!--            <th><?php echo $this->Paginator->sort('id'); ?></th>-->
            <th><?php echo $this->Paginator->sort('Letra', 'letter'); ?></th>
            <th><?php echo $this->Paginator->sort('Numero', 'number'); ?></th>
            <th><?php echo $this->Paginator->sort('Marca', 'mark'); ?></th>
            <th><?php echo $this->Paginator->sort('Modelo', 'model'); ?></th>
            <th><?php echo $this->Paginator->sort('N° Chasis', 'chassis_number'); ?></th>
            <th><?php echo $this->Paginator->sort('Titular', 'client_id'); ?></th>
            <th class="actions"><?php __('Opciones'); ?></th>
        </tr>
        <?php
        $i = 0;
//        pr($cars);die;
        foreach ($cars as $car):
            $class = null;
            if ($i++ % 2 == 0) {
                $class = ' class="altrow"';
            }
            ?>
            <tr<?php echo $class; ?>>
    <!--                <td><?php echo $car['Car']['id']; ?>&nbsp;</td>-->
                <td><?php echo $car['Car']['letter']; ?>&nbsp;</td>
                <td><?php echo $car['Car']['number']; ?>&nbsp;</td>
                <td><?php echo $car['Car']['mark']; ?>&nbsp;</td>
                <td><?php echo $car['Car']['model']; ?>&nbsp;</td>
                <td><?php echo $car['Car']['chassis_number']; ?>&nbsp;</td>
                <td>
    <?php echo $this->Html->link($car['Client']['last_name'] . ' ' . $car['Client']['first_name'], array('controller' => 'clients', 'action' => 'view', $car['Client']['id'])); ?>
                </td>
                <td class="actions">
                    <?php echo $this->Html->link(__('Ver', true), array('action' => 'view', $car['Car']['id'])); ?>
                    <?php 
                    if(sizeof($car['Key']) == 0){
                        echo $this->Html->link(__('Agregar Llave', true), array('action' => 'agregar_llave', $car['Car']['id']));
                    }else{
                        echo $this->Html->link(__('Agregar Copia', true), array('controller'=>'keys', 'action' => 'agregar_copia', $car['Key'][0]['id']));
                    } ?>
                    <?php echo $this->Html->link(__('Editar', true), array('action' => 'edit', $car['Car']['id'])); ?>
    <?php echo $this->Html->link(__('Eliminar', true), array('action' => 'delete', $car['Car']['id']), null, sprintf(__('Esta seguro que desea eliminar el auto # %s?', true), $car['Car']['letter'] . ' ' . $car['Car']['number'])); ?>
                </td>
            </tr>
<?php endforeach; ?>
    </table>
    <p>
        <?php
        echo $this->Paginator->counter(array(
            'format' => __('Página %page% de %pages%, mostrando %current% registros de %count% en total, a partir del registro %start%, terminando en el %end%', true)
        ));
        ?>	</p>

    <div class="paging">
<?php echo $this->Paginator->prev('<< ' . __('anterior', true), array(), null, array('class' => 'disabled')); ?>
        | 	<?php echo $this->Paginator->numbers(); ?>
        |
<?php echo $this->Paginator->next(__('siguiente', true) . ' >>', array(), null, array('class' => 'disabled')); ?>
    </div>
</div>